/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package compevol;

/**
 *
 * @author vitor
 */
public class Funcao4 implements Fitness {

    //Função generalizada de Schwefel 1.2
    public double avalia(Individuo ind) {
        double[] valor = ind.valores();
        double sum = 0;
        int n = valor.length;
        for (int i = 0; i < n; i++) {
            double internalSum = 0;
            for (int j = 0; j < n; j++) {
                internalSum += valor[j];
            }
            sum+= Math.pow(internalSum, 2);
        }
        return sum;
    }

    @Override
    public String toString() {
        return "F4";
    }
}
